:root {
  --bg-primary: #0D0D0D;
  --bg-card: #141414;
  --text-primary: #EAEAEA;
  --text-secondary: #A0A0A0;
  --accent-gold: #D4AF37;
  --accent-gold-hover: #E5C158;
  --border-gold: rgba(212, 175, 55, 0.2);
  --border-radius: 12px;
  --transition: all 0.3s ease;
  --modal-bg: rgba(13, 13, 13, 0.85);
}
body.light-theme {
  --bg-primary: #F5F5F5;
  --bg-card: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #555555;
  --border-gold: rgba(212, 175, 55, 0.5);
  --modal-bg: rgba(245, 245, 245, 0.85);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: var(--transition);
  opacity: 0;
  animation: pageFadeIn 0.8s forwards;
}
@keyframes pageFadeIn {
  to { opacity: 1; }
}

h1, h2, h3 { font-weight: 400; letter-spacing: 0.5px; }
p { line-height: 1.6; }

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 5%;
  border-bottom: 1px solid var(--border-gold);
  background-color: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 1.5rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
}
.nav-search input {
  width: 350px;
  padding: 0.75rem 1.25rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--text-primary);
  border-radius: 8px;
  outline: none;
  transition: var(--transition);
}
.nav-search input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}
.nav-controls {
  display: flex;
  gap: 1rem;
}

.btn-outline {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn-outline:hover {
  background-color: var(--accent-gold);
  color: #000;
}

.controls-panel {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1rem 5%;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-gold);
}
.filter-group, .sort-group, .limit-group, .reset-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.filter-group label, .sort-group label, .limit-group label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.filter-group input, .sort-group select, .limit-group select {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
  padding: 0.5rem;
  border-radius: 4px;
  outline: none;
}


.active-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 5%;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-gold);
}
.active-filters:empty {
  display: none;
}
.active-tag {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.remove-tag {
  cursor: pointer;
  color: var(--accent-gold);
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  transition: var(--transition);
}
.remove-tag:hover {
  color: var(--bg-primary);
  background-color: var(--accent-gold);
}

.hero {
  text-align: center;
  padding: 4rem 2rem;
}
.hero h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 300;
}

.main-content {
  padding: 2rem 5%;
  max-width: 1400px;
  margin: 0 auto;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2.5rem;
}

.book-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.book-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.15);
  border-color: var(--accent-gold-hover);
}
.book-cover {
  width: 100%;
  height: 380px;
  object-fit: cover;
  border-bottom: 1px solid var(--border-gold);
  background-color: #222;
}
.book-info {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.book-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.book-author, .book-year {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}
.card-actions {
  margin-top: auto;
  padding-top: 1rem;
}
.btn-favorite {
  width: 100%;
  padding: 0.6rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-favorite:hover, .btn-favorite.active {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.state-container {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}
.hidden {
  display: none !important;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent-gold);
  animation: spin 1s ease-in-out infinite;
  margin: 0 auto 1.5rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-bg);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}
@keyframes fadeIn {
  to { opacity: 1; }
}
.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--accent-gold);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.close-btn:hover {
  color: var(--accent-gold);
}
.modal-body {
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
  gap: 2.5rem;
}
.modal-image-container img {
  width: 100%;
  max-width: 300px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.modal-info {
  flex-grow: 1;
}
.modal-info h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.author-text {
  font-size: 1.2rem;
  color: var(--accent-gold);
  font-weight: 300;
  margin-bottom: 0.25rem;
}
.year-text {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.tag {
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid var(--border-gold);
}
.description-container h3 {
  font-size: 1.1rem;
  color: var(--accent-gold);
  margin-bottom: 1rem;
}
.description-container p {
  color: var(--text-primary);
  line-height: 1.8;
  font-weight: 300;
}

@media (min-width: 768px) {
  .modal-body {
    flex-direction: row;
  }
}
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 1.5rem;
  }
  .nav-search input {
    width: 100%;
  }
  .controls-panel {
    flex-direction: column;
    align-items: center;
  }
}